-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print optimal number of maPCA components and plot optimization curves #839
Conversation
@handwerkerd I don't know what you want the |
I was hoping to read this carefully today, but it's not going to happen. I'll try to give a closer read soon. When I was discussing, tedana/tedana/selection/selection_nodes.py Lines 647 to 652 in f011ba2
The basic idea is to have a dictionary for all values that are calculated based on metrics across components (i.e. the kappa and rho elbows). The complements the component table, where each metric has a value for each component. In the current code, these cross component values are either in the log and nowhere else or not saved at all. Since you're criterion thresholds are the same general concept, I figured you could create a similar dictionary with a similar naming style. |
Codecov Report
@@ Coverage Diff @@
## main #839 +/- ##
==========================================
+ Coverage 93.15% 93.31% +0.16%
==========================================
Files 27 27
Lines 2234 2304 +70
==========================================
+ Hits 2081 2150 +69
- Misses 153 154 +1
Continue to review full report at Codecov.
|
The three-echo test should pass once we merge PR #50 in maPCA. |
The test will pass once PR #50 is merged in maPCA. |
I just tried to locally run the three-echo test with mapca after #50 was merged. The test is still failing in io.py with
The four-echo test is passing so this isn't a universal issue. I'm not sure I have time to dig into this more right now, but wanted to share. |
I think we need to automatically convert numpy arrays to lists in |
voxel_comp_weights = ma_pca.u_ | ||
varex = ma_pca.explained_variance_ | ||
varex_norm = ma_pca.explained_variance_ratio_ | ||
comp_ts = ma_pca.components_.T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like we're accessing private components of the object. Could we either link to some documentation about the returned object or elaborate on what we're accessing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trailing underscore indicates that the attribute is estimated from the data (via fit
), rather than that it's private. We adopted this convention from scikit-learn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that makes sense. Sorry had a momentary flip in my brain, where I put the underscore on the wrong side. I do think it's worth a quick reference to the docs.
tedana/info.py
Outdated
@@ -29,7 +29,7 @@ | |||
|
|||
REQUIRES = [ | |||
"bokeh<2.3.0", | |||
"mapca~=0.0.1", | |||
"mapca>=0.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we'll need to resolve the conflict with main where we've moved everything into a different setup organization (in particular, setup.cfg
in the install_requires
section).
@@ -288,3 +288,144 @@ def comp_figures(ts, mask, comptable, mmix, io_generator, png_cmap): | |||
compplot_name = os.path.join(io_generator.out_dir, "figures", plot_name) | |||
plt.savefig(compplot_name) | |||
plt.close() | |||
|
|||
|
|||
def pca_results(criteria, n_components, all_varex, io_generator): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function has a large amount of repetition. Could we break it into smaller functions, parametrized perhaps by something like the input data and the label only, and if matplotlib requires this, the figure itself?
Hi Eneko, I left some comments but didn't formally review. Let me know if you'd like for me to fix the merge conflicts and some of the refactors I mentioned as possibilities for you. However I do think it's worth considering some more documentation about how we're extracting these values from the mapca object. |
Feel free to make the changes. I won't be able to work on this until I come back from ISMRM. Thank you for the comments by the way! |
Resolves conflicts: - info.py: deletes and moves dependency version to setup.cfg - cornell_three_echo_outputs: adds pca_criteria.png, keeps main outputs
Hm, I merged the changes but it seems like some expected attribute is missing. It looks like CircleCI is just caching the last environment, so that it's not checking the versions in |
@eurunuela I think you need to cut a new release with the changes so that we can pin that release. |
Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @eurunuela !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM.
The one thing I notices is that a file called ./figures/pca_variance_explained.png
It looks similar to the relevant file ./figures/pca_criteria.png
but it just contains the vertical dashed lines without the criteria curves. My guess is that this was useful while working on the code, but isn't useful as a saved output. If I'm right, just don't save that file?
I'm sorry @handwerkerd, that was a mistake on my end. Here's what the figure should look like: I'm committing the fix now. |
Yay! That does look useful and I'm glad I noticed. In your sample figure above, I don't see a blue dashed line for AIC. |
That's because it's right behind the KIC line. The figure was generated with the 3 echo integration test by the way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Closes #834 .
Changes proposed in this pull request:
Edit: this draft PR will fail until #47 and #48 are merged in maPCA.